package com.wwwzh.himalayafm.adapter.recommend;

import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.wwwzh.himalayafm.entity.recommend.RecommendEntityOne;

import java.util.List;

/**
 * Created by weizz on 2016/12/6.
 */

public class RecommDisAdapter extends PagerAdapter {


    private LayoutInflater inflater;
    private RecommendEntityOne entityOne;
    private List<View> list;
//    private List<RecommendDiscovery> list;
    public RecommDisAdapter(List<View> list) {
//        this.inflater = inflater;
//        this.entityOne = entity;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {

//        if (position==0){
//            ViewDataBinding binding = DataBindingUtil.inflate(inflater, R.layout.layout_recomm_dis_view, null, false);
//            binding.setVariable(BR.discovery,entityOne.getDiscoveryColumns());
//            container.addView(binding.getRoot());
//            Log.d("1620","binding created");
//            return binding.getRoot();
//        }else{
//            List<RecommendDisItem> halfList = new ArrayList<>();
//            for (int i = 0; i<4; i++) {
//                halfList.add(entityOne.getDiscoveryColumns().getList().get(i+4));
//            }
//            ViewDataBinding binding2 = DataBindingUtil.inflate(inflater, R.layout.layout_recomm_dis_view, null, false);
////            entityOne.getDiscoveryColumns().setList(halfList);
//            RecommendEntityOne.RecommendDiscovery discovery = entityOne.getDiscoveryColumns();
//            discovery.setList(halfList);
//            binding2.setVariable(BR.discovery,discovery);
//            container.addView(binding2.getRoot());
//            Log.d("1620","binding2 created");
//
//        ViewDataBinding binding = DataBindingUtil.inflate(inflater, R.layout.layout_recomm_dis_view, null, false);
//        binding.setVariable(BR.discovery,list.get(position));
            container.addView(list.get(position));
            return list.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }
}
